package top.lixunda.books3.model;

import com.sun.istack.internal.NotNull;

public class Message {

    /**
     * 返回状态码
     */
    private int code;

    /**
     * 状态码说明信息
     */
    private String message;

    /**
     * 请求数据的总量
     */
    private long total;

    /**
     * 返回数据的数量
     */
    private long count;

    /**
     * 从第几条数据开始
     */
    private long first;

    private Object data;

    public int getCode() {
        return code;
    }

    public Message setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public Message setMessage(String message) {
        this.message = message;
        return this;
    }

    public long getTotal() {
        return total;
    }

    public Message setTotal(long total) {
        this.total = total;
        return this;
    }

    public long getCount() {
        return count;
    }

    public Message setCount(long count) {
        this.count = count;
        return this;
    }

    public long getFirst() {
        return first;
    }

    public Message setFirst(long first) {
        this.first = first;
        return this;
    }

    public Object getData(){
        return this.data;
    }

    public Message setData(Object data){
        this.data = data;
        return this;
    }

    //请求成功 200
    public static Message success(){
        return new Message().setCode(200).setMessage("请求已正常处理完毕");
    }
    //请求成功 200
    public static Message successData(Object data){
        return new Message().setCode(200).setMessage("请求成功").setData(data);
    }
    //参数缺失 401
    public static Message errorClientParamsMiss(@NotNull String message){
        return new Message().setCode(401).setMessage(message);
    }
    //参数格式错误 402
    public static Message errorClientParamsFormat(){
        return new Message().setCode(402).setMessage("客户端上传参数格式错误");
    }
    //参数格式错误 402
    public static Message errorClientParamsFormat(@NotNull String message){
        return new Message().setCode(402).setMessage(message);
    }
    //验证码错误 403
    public static Message errorClientVerify(){
        return new Message().setCode(403).setMessage("验证码错误");
    }
    //用户不存在 404
    public static Message errorClientNoUser(){
        return new Message().setCode(404).setMessage("用户不存在");
    }
    //密码错误 405
    public static Message errorClientErrPass(){
        return new Message().setCode(405).setMessage("密码错误");
    }
    //手机号码格式错误 406
    public static Message errorClientErrPhone(){
        return new Message().setCode(406).setMessage("不是正确的手机号码");
    }
    //密码格式错误 407
    public static Message errorClientPassFormat(){
        return new Message().setCode(407).setMessage("密码格式错误");
    }
    //短信验证码错误或已经给过期 408
    public static Message errorClientSmsVerify(){
        return new Message().setCode(408).setMessage("短信验证码错误或验证码已过期");
    }
    //手机号码已注册 409
    public static Message errorClientDoublePhone(){
        return new Message().setCode(409).setMessage("手机号码已经注册过，可直接登陆");
    }
    //服务器端错误 500
    public static Message errorServer(@NotNull String message){
        return new Message().setCode(500).setMessage(message);
    }

}
